package com.gzhu.knowledgeAdmin.controller;

import com.gzhu.knowledgeAdmin.common.result.R;
import com.gzhu.knowledgeAdmin.common.valid.AddGroup;
import com.gzhu.knowledgeAdmin.common.valid.UpdateGroup;
import com.gzhu.knowledgeAdmin.common.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.gzhu.knowledgeAdmin.entity.CheckResult;
import com.gzhu.knowledgeAdmin.service.CheckResultService;

import java.util.Map;
import java.util.List;

/**
 * 质检结果表
 *
 * @author yangminggui
 * @email giaogiao@gmail.com
 * @date 2024-02-23 22:58:54
 */
@RestController
@RequestMapping("knowledgeAdmin/checkResult")
public class CheckResultController {
    @Autowired
    private CheckResultService checkResultService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageVo page = checkResultService.queryPage(params);
        return R.ok(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		CheckResult checkResult = checkResultService.getById(id);
        return R.ok(checkResult);
    }

    /**
     * 添加
     */
    @PostMapping("/save")
    public R save(@RequestBody @Validated(AddGroup.class) CheckResult checkResult){
		checkResultService.save(checkResult);
        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody @Validated(UpdateGroup.class) CheckResult checkResult){
            checkResultService.updateById(checkResult);
        return R.ok();
    }


    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody List<Integer> ids){
		checkResultService.removeByIds(ids);
        return R.ok();
    }

    /**
     * 复核检测结果
     * @param ids
     * @return
     */
    @PostMapping("/reCheck")
    public R reCheck(@RequestBody List<Integer> ids){
        checkResultService.reCheckBatch(ids);
        return R.ok();
    }

}
